package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	text := make([]string, 4)
	var P string

	fi, err := os.Open(".shhrc")
	if err != nil {
		P = ">>>"
	}
	defer fi.Close()

	scanner := bufio.NewScanner(fi)
	for scanner.Scan() {
		P = scanner.Text() + " "
	}

	if err := scanner.Err(); err != nil {
		os.Exit(1)
	}

	for {
		fmt.Printf("%s", P)
		fmt.Scanf("%s\n", &text)

		switch {
		case text[0] == "exit":
			fmt.Printf("exit\n")
			os.Exit(0)
		case text[0] == "echo":
			for i := 1; i < len(text)-1; i++ {
				fmt.Printf("%s\n", text[i])
			}
		default:
			fmt.Printf("%s: command not found\n", text[0])
		}
	}
}
